package com.miyuan.wm.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.miyuan.wm.mapper.RecordStorageMapper;
import com.miyuan.wm.pojo.RecordStorageEntity;
import com.miyuan.wm.request.QueryRecordStorageRequestVo;
import com.miyuan.wm.response.PageResponse;
import com.miyuan.wm.response.QueryRecordStorageResponseVo;
import com.miyuan.wm.service.StorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.validation.Valid;
import java.util.List;

/**
 * @ClassName StorageServiceImpl
 * @Description 库存管理接口业务类
 */
@Service
@Slf4j
public class StorageServiceImpl implements StorageService {

    @Autowired
    private RecordStorageMapper recordStorageMapper;

    @Override
    public PageResponse<List<QueryRecordStorageResponseVo>> listRecordStorage(@Valid QueryRecordStorageRequestVo requestVo) {
        Page<RecordStorageEntity> page = new Page<>(requestVo.getPageNumber(), requestVo.getPageSize());
        List<QueryRecordStorageResponseVo> queryRecordStorageResponseVos = recordStorageMapper.listRecordStorage(page, requestVo);
        return PageResponse.newInstance(queryRecordStorageResponseVos, page.getTotal(), page.getCurrent(), page.getSize());
    }
}
